#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "room.hpp"
#include <QMainWindow>
#include <QtNetwork/QTcpSocket>
#include <QJsonObject>
#include <QJsonDocument>
#include <QMessageBox>
#include <QTimer>
#include <QtEndian>

namespace Ui {
    class MainWindow;
};

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QString _roomNo,QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    QTcpSocket *mySocket;
    QString hostAddress;
    int portToConnect;
    quint32 dataSize;
    QDataStream in;
    room myRoom;
    QTimer *timer;

    int t_wind;
    double t_temperature;

private slots:
    void connectToHost();
    void sendBlock(QByteArray* p_block);
    void response();
    void showStatus();
    void setTWind(int idx);
    void setTTemperature();
    void setData();
    void launch();
signals:
    void finishParse(bool _isOpen,double _temperature,int _wind,double _cost,bool _isServed);
};

#endif // MAINWINDOW_H
